﻿using Entity.order;
using Entity.shangping;
using Entity.user;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
using System.Web;

namespace DAO.db
{
    public class EFDbContext : DbContext
    {
        //修改类文件EFDbContext.cs的静态构造函数，取消当数据库模型发生改变时删除当前数据库重建新数据库的设置。
        static EFDbContext()
        {
            //Database.SetInitializer<EFDbContext>(null);
        }

        /// <summary>
        /// 模型配置重写
        /// </summary>
        /// <param name="modelBuilder">数据实体生成器</param>
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            // 禁用一对多级联删除
            modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
            // 禁用多对多级联删除
            modelBuilder.Conventions.Remove<ManyToManyCascadeDeleteConvention>();
            // 禁用表名自动复数规则
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();

        }

        public DbSet<Goods> Goodss { get; set; }
        public DbSet<GoodsType> GoodsTypes { get; set; }
        public DbSet<ShopCar> ShopCars { get; set; }

        public DbSet<Address> Addresss { get; set; }
        public DbSet<User> Users { get; set; }
        public DbSet<Details> Detailss { get; set; }
        public DbSet<Order> Orders { get; set; }

    }
}
